package HomeWork;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class test2 {
    public static void main(String[] args) {
        ArrayList<String> one = new ArrayList<>();
        one.add("教父");
        one.add("肖申克的救赎");
        one.add("辛德勒的名单");
        one.add("公民凯恩");
        one.add("卡萨布兰卡");
        one.add("教父续集");
        one.add("七武士");
        one.add("星球大战");
        one.add("美国美人");
        one.add("飞跃疯人院");

        ArrayList<String> two = new ArrayList<>();
        two.add("霸王别姬");
        two.add("大闹天宫");
        two.add("鬼子来了");
        two.add("大话西游");
        two.add("活着");
        two.add("饮食男女");
        two.add("无间道");
        two.add("天书奇谭");
        two.add("哪吒脑海");
        two.add("春光乍泄");
//        1）打印全球影片排行榜中的前三甲影片名
        List<String> collect = one.stream().limit(3).collect(Collectors.toList());
        Stream<String> one1 = collect.stream();
//        2）打印华人影片排行榜中倒数5名的影片名
        List<String> collect1 = two.stream().skip(5).collect(Collectors.toList());
        Stream<String> two2 = collect1.stream();
//        3）将两个排行榜中的前5名挑出来共同存入新的集合
        ArrayList<String> move = new ArrayList<>();
         Stream.concat(one1, two2).forEach(s -> {
             Film film = new Film(s);
             move.add(String.valueOf(film));
         });
        for (int i = 0; i < move.size(); i++) {
            System.out.println(move.get(i));
        }


//        4）定义电影Film类，以影片名为name创建Film对象并保存至集合
    }
}
class Film{
private String move;

    public Film() {
    }

    public Film(String move) {
        this.move = move;
    }

    public String getMove() {
        return move;
    }

    public void setMove(String move) {
        this.move = move;
    }

    @Override
    public String toString() {
        return "Film{" +
                "move=" + move +
                '}';
    }
}
